<?php 

class Throughput {
	
	var $db;
	var $id;
	var $classAndMethod;
	var $startTime;
	
	function __construct($identifier)
	{
		$this->classAndMethod = $identifier;
		$this->db = new ezSQL_mysql(USERNAME, PASSWORD, DATABASE, HOSTNAME);
		$this->id = uniqid('', true);
		$this->startTime = $this->getmicrotime();
		$this->db->query("INSERT INTO throughput (method, uniqid, response, microtime) 
						   VALUES ('$this->classAndMethod', '$this->id', '0', '$this->startTime')");
		
	}

	function getmicrotime()
	{
	    list($u, $s) = explode(' ',microtime());
	    return bcadd($u, $s, 8);
	}
	
	function __destruct()
	{
		$this->db->query("UPDATE throughput SET response = '1', uniqid='' WHERE uniqid = '$this->id'");
	}
	
	
}

//EOF Throughput.php
